<template>
	<view class="content">
		<view class="topContent">
			<view class="top">
				<image src="../../static/index/back.png" class="rightImg" @tap="back"></image>
				实名认证
			</view>
			<image src="../../static/authentication/step2.png" class="stepImg"></image>
		</view>
		<!-- 人脸识别 -->
		<view class="upContent">
			<view class="sureTetx">确认{{realName}}本人操作</view>
			<view class="text">请保持正脸在取景框中根据屏幕指示完成识别</view>
		  <!-- <image src="../../static/authentication/round.png" class="round"></image> -->
		</view>
		<view class="next" @tap="next">开始识别</view>
	</view>
</template>

<script>
	import { describeFaceVerify } from '../../api/api.js'
	const n = uni.requireNativePlugin('AP-FaceDetectModule');
	export default {
		data() {
			return {
				certifyId:'',
				id:'',
				realName:'',
			}
		},
		onLoad(e) {
			this.certifyId = e.certifyId
			this.id = e.id
			this.realName = e.realName
		},
		methods: {
			back() {
				uni.navigateBack({
					delta:1
				})
			},
			next() {
				var that = this
				n.verify(
				  {
				    certifyId: that.certifyId
				  },
				  function(t) {
						if( t.code == 1000 ) {
							let data = {
								id:that.id,
								certifyId:that.certifyId
							}
							describeFaceVerify(data).then( res=> {
								if( res.code == 200 ) {
									uni.redirectTo({
										url:'./success'
									})
								}
							})
						}else {
							uni.showToast({
								title:'认证失败，请稍后重试',
								icon:'none'
							})
							setTimeout(function() {
								uni.redirectTo({
									url:'./ID'
								})
							},1000)
						}
				  }
				);
			}
		}
	}
</script>

<style lang="less" scoped>
	.content {
		.topContent {
			display: flex;
			flex-direction: column;
			align-items: center;
			padding-top: 76rpx;
			width: 750rpx;
			height:244rpx;
			background: linear-gradient(360deg, #3D8DFF 0%, #1274FF 100%);
			.top{
				position: relative;
				width: 750rpx;
				text-align: center;
				font-size: 36rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #FFFFFF;
				line-height: 50rpx;
				.rightImg {
					position: absolute;
					top: 9rpx;
					left: 36rpx;
					width: 18rpx;
					height: 32rpx;
				}
			}
			.stepImg {
				margin-top: 60rpx;
				width: 630rpx;
				height: 99rpx;
			}
		}
		// 人脸识别
		.upContent {
			margin-top: 50rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			.sureTetx {
				font-size: 32rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #1A1A1A;
				line-height: 45rpx;
			}
			.text {
				margin: 16rpx 0 44rpx 0;
				font-size: 26rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #999990;
				line-height: 37rpx;
			}
			.round {
				width: 412rpx;
				height: 412rpx;
			}
		}
		.next {
			margin: 290rpx 0 0 32rpx;
			text-align: center;
			width: 686rpx;
			height: 90rpx;
			background: #FE3B33;
			box-shadow: 0rpx 2rpx 4rpx 0rpx rgba(0, 0, 0, 0.16);
			border-radius: 8rpx;
			font-size: 30rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
			line-height: 90rpx;
		}
	}
</style>
